﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using TestStarter.Wpf.WpfPage;

namespace TestStater.Wpf.WpfWindow
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private static MainWindow instance;

        private MainWindow()
        {
            InitializeComponent();
            ContentFrame.Content = new SettingsPage();
            instance = this;
            
        }

        public static MainWindow Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new MainWindow();
                }

                return instance; 
            }
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void OnDragMoveWindow(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }

        private void OnMinimizeWindow(object sender, MouseButtonEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void OnMaximizeWindow(object sender, MouseButtonEventArgs e)
        {
            if (this.WindowState == WindowState.Maximized)
                this.WindowState = WindowState.Normal;
            else if (this.WindowState == WindowState.Normal)
                this.WindowState = WindowState.Maximized;
        }

        private void OnCloseWindow(object sender, MouseButtonEventArgs e)
        {
            this.Close();
            Application.Current.Shutdown();
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        public void TransferToTestsConfigurationPage()
        {
            ContentFrame.Content = null;
            ContentFrame.Content = new TestsConfigurationPage();
        }

        public void TransferToSettingsPage()
        {
            ContentFrame.Content = null;
            ContentFrame.Content = new SettingsPage();
        }

        private void TransferToReportsPage()
        {
            ContentFrame.Content = null;
            ContentFrame.Content = new TestsReportsPage();
        }

        private void TestPageButton_Click(object sender, RoutedEventArgs e)
        {
            TransferToTestsConfigurationPage();
        }

        private void ConfigPageButton_Click(object sender, RoutedEventArgs e)
        {
            TransferToSettingsPage();
        }

        private void ReportPageButtonButton_Click(object sender, RoutedEventArgs e)
        {
            TransferToReportsPage();
        }

        private void GenarateDataPageButton_Click(object sender, RoutedEventArgs e)
        {
            ContentFrame.Content = null;
            ContentFrame.Content = new GenarateDataPage();
            
        }
    }
}
